package com.nd.test.service;

import java.util.List;
import java.util.Date;

import model.po.CouponsSendingCondition;
import com.nd.test.vo.CouponsSendingConditionVo;
import com.nd.test.repository.CouponsSendingConditionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**   
 * Create by apisdk 
 */
@Service
public class CouponsSendingConditionService {
	@Autowired
	private CouponsSendingConditionRepository couponsSendingConditionRepository;

	/**
	* @description create model
	* @return
	*/
	public CouponsSendingConditionVo createCouponsSendingCondition(CouponsSendingConditionVo couponsSendingConditionVo) throws Exception {
		CouponsSendingCondition couponsSendingCondition = new CouponsSendingCondition();
		BeanUtils.copyProperties(couponsSendingConditionVo, couponsSendingCondition);
		couponsSendingCondition =  couponsSendingConditionRepository.save(couponsSendingCondition);
		BeanUtils.copyProperties(couponsSendingCondition, couponsSendingConditionVo);
		return couponsSendingConditionVo;
	}

	/**
	* @description get model through id
	* @return
	*/
	public List<CouponsSendingConditionVo></Vo> getCouponsSendingConditionByExample(CouponsSendingConditionVo couponsSendingConditionVo){
		CouponsSendingCondition couponsSendingCondition = new CouponsSendingCondition();
		BeanUtils.copyProperties(couponsSendingConditionVo, couponsSendingCondition);
	}

	/**
	* @description update model through id
	* @return
	*/
	public CouponsSendingConditionVo updateCouponsSendingConditionById(@PathVariable String id,@RequestBody CouponsSendingConditionVo couponsSendingConditionVo){
		//TODO to finish update code
		return couponsSendingConditionVo;
	}

	/**
	* @description delete model through id
	* @return
	*/
	public void deleteCouponsSendingConditionById(@PathVariable String id){
		CouponsSendingCondition couponsSendingCondition =  couponsSendingConditionRepository.findOne(id);
		if(couponsSendingCondition!=null){
			couponsSendingConditionRepository.delete(couponsSendingCondition);
		}
		return;
	}

}
